//
//  HWMyCurrencyViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/11/15.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWMyCurrencyViewController.h"
#import "HWbangbinTableViewCell.h"
#import "HWbangbiModel.h"
@interface HWMyCurrencyViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(strong,nonatomic)UITableView *mainaTableVie;
@property(strong,nonatomic) NSMutableArray *dataMutaArr; //
@end

@implementation HWMyCurrencyViewController

-(UITableView *)mainaTableVie {

    if (_mainaTableVie == nil
        ) {

         _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW,kScreenH) style:UITableViewStylePlain];
         _mainaTableVie.delegate = self;
         _mainaTableVie.dataSource = self;
         _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
         _mainaTableVie.backgroundColor = [UIColor whiteColor];
       //  _mainaTableVie.sectionHeaderHeight = 44;
        

    }
    return   _mainaTableVie ;
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setUPUI];
    
    [self fasongwangluoqing];
    
    
    
    
}





- (void)fasongwangluoqing {
    
    
      self.dataMutaArr = [[NSMutableArray alloc]init];
      NSString *userID = [HWLocallyStoredData getLoginUserID];
    
       int  suiJi =  [WMUtil getRandomNumber:101 to:998];
       NSString *tStr = [NSString stringWithFormat:@"%ld%d",[WMUtil getTimeSp],suiJi];
       NSString *sign = [NSString stringWithFormat:@"%@%@%@",userID,tStr,@"fsd213ewdsadqwe2121213edsad"];
       NSString *signMD5 = [WMUtil md5HexDigest:sign];
       NSDictionary *parametes = @{
                                   @"ct" :  @"app",
                                   @"ac" : @"mybind",
                                   @"ios" : @"1",
                                   @"uid" :userID,
                                   @"t" :tStr,
                                   @"sign": signMD5,
                
                                   
                                   };
       

      // [MBProgressHUD show:@"正在删除小号"];
       [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
           
         
           NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        //   [MBProgressHUD hideHUD];
           
           
           if ([codeStr intValue] == 1) {
            
               self.dataMutaArr = [HWbangbiModel mj_objectArrayWithKeyValuesArray:response[@"data"]];
               
            


           } else {
               
                [MBProgressHUD  showError:response[@"message"]];
               
           }
           
           [self.mainaTableVie reloadData];
           NSLog(@"%@",response);
           
           
       } failure:^(NSString *error) {
         
           [MBProgressHUD  showError:@"查询失败"];
           
       }];
    
    
    
    
}




- (void)setUPUI {
    
    
    [self.view addSubview:self.mainaTableVie];
    self.navigationItem.title = @"我的绑币";
    
    self.navigationItem.title = [HWjianzhiduiObject keylocalization:@"我的绑币"];
    self.view.backgroundColor = [UIColor whiteColor];
    [self addheaderView];
}


- (void)addheaderView {
    
    
     UIView *headeview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 44)];
    
    self.mainaTableVie.tableHeaderView = headeview;
    
    
    
      UILabel  *xiahao1mingz  = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kScreenW/2,44)];
        xiahao1mingz.text = @"游戏名称";
    xiahao1mingz.text  =  [HWjianzhiduiObject keylocalization:@"游戏名称"];
      
        xiahao1mingz.font = [UIFont systemFontOfSize:13];
        xiahao1mingz.textColor = RGB(51,51,51);
        xiahao1mingz.numberOfLines = 2;
        xiahao1mingz.backgroundColor = RGB(233,241, 255);
        xiahao1mingz.textAlignment = NSTextAlignmentCenter;
        [headeview addSubview:xiahao1mingz];
                    
         UILabel  *zhuceshijian  = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW/2, 0, kScreenW/2, 44)];
           zhuceshijian.text = @"绑币余额";
    zhuceshijian.text  =  [HWjianzhiduiObject keylocalization:@"绑币余额"];
           zhuceshijian.font = [UIFont systemFontOfSize:13];
           zhuceshijian.textColor = RGB(51,51,51);
            zhuceshijian.numberOfLines = 2;
            zhuceshijian.textAlignment = NSTextAlignmentCenter;
          zhuceshijian.backgroundColor = RGB(233,241, 255);
          [headeview addSubview:zhuceshijian];
      
       UIView *shuxianView = [[UIView alloc]initWithFrame:CGRectMake(kScreenW/2, 0, 1, 44)];
       shuxianView.backgroundColor =  RGB(232, 232, 242);
       [headeview addSubview:shuxianView];
     
    
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    return self.dataMutaArr.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *cellID = @"cellID";
    HWbangbinTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[HWbangbinTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    cell.backgroundColor = [UIColor whiteColor];
    cell.selectionStyle =  UITableViewCellSelectionStyleNone;
    
    HWbangbiModel *model =  self.dataMutaArr[indexPath.row];
    cell.model = model;
    
    return  cell;
}



- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    return  44;
    
    
}



@end
